#!/bin/bash

if [ ! -f /tmp/lock_populate_xenia_nos ]; then
  touch /tmp/lock_populate_xenia_nos

  startTime=`date -u`
  echo "Start time: $startTime\n" > /home/xeniaprod/tmp/log/scout_nos.log 2>&1
  
  /home/xeniaprod/scripts/postgresql/feeds/federal/mk_sql_for_xenia.pl nos 24 /home/xeniaprod/tmp/sqlfiles/nos.sql debug >> /home/xeniaprod/tmp/log/scout_nos.log 2>&1
  psql -U xeniaprod -d xenia -f /home/xeniaprod/tmp/sqlfiles/nos.sql >> /home/xeniaprod/tmp/log/scout_nos.log 2>&1
  rm -f /tmp/lock_populate_xenia_nos

  startTime=`date -u`
  echo "\nEnd time: $startTime" >> /home/xeniaprod/tmp/log/scout_nws.log 2>&1

else
  startTime=`date -u`
  echo "Lock file exists, cannot run script: $startTime\n" >> /home/xeniaprod/tmp/log/scout_nws.log 2>&1  
fi